import loadingSrc from "../assets/loading.svg";

export default function (el, binding){
    if(!binding.value){
        const img = el.querySelector("img[data-loading='loading']");
        img && img.remove();
        return;
    }
    el.style.position = "relative";
    const img = document.createElement("img");
    img.dataset.loading = "loading";
    img.src = loadingSrc;
    img.style.position = "absolute";
    img.style.left = "50%";
    img.style.top = "50%";
    img.style.transform = "translate(-50%, -50%)";
    el.appendChild(img);
}